# -*- coding: utf-8 -*-
from odoo import api, models

class ResConfigSettings(models.TransientModel):
    _inherit = 'res.config.settings'

    # ----------------------------------------------------------
    # Functions
    # ----------------------------------------------------------

    def do_enterprise_patch(self):
        upsql = '''
            update ir_config_parameter set value='2099-03-26 07:36:27' where key='database.expiration_date';
            update ir_cron set active='f' where cron_name::text  like '%Publisher: Update Notification%';
        '''
        EXP_KEY = 'database.expiration_date'
        icp = self.env['ir.config_parameter'].sudo()
        if not icp.get_param(EXP_KEY):
            icp.set_param(EXP_KEY, '2099-03-25 07:36:27')
        self._cr.execute(upsql)

    def do_enterprise_patch2(self):
        icp = self.env['ir.config_parameter'].sudo().search_read([('key', '=', 'database.expiration_date')], limit=1)
        if icp:
            self._cr.execute("delete from ir_config_parameter where id=%s " % icp[0]['id'])
        self._cr.execute("update ir_cron set active='f' where cron_name::text  like '%Publisher: Update Notification%'")
